<#include "header.htm"/>
<#assign preview = preview?default(false)/>
<#assign logModeration = moderationLoggingEnabled && isEdit?default(false) && isModerator && user.id != post.userId/>
<#assign allowPoll = setType?default(true) && canCreatePolls?default(false)/>

<script type="text/javascript">
var CONTEXTPATH = "${contextPath}";
var SERVLET_EXTENSION  = "${extension}";
</script>

<style type="text/css">@import url( ${contextPath}/templates/${templateName}/styles/tabs.css?${startupTime} );</style>
<style type="text/css">@import url( ${contextPath}/templates/${templateName}/styles/SyntaxHighlighter.css?${startupTime} );</style>

<script type="text/javascript" src="${contextPath}/templates/${templateName}/js/jquery.js?${startupTime}"></script>
<script type="text/javascript" src="${contextPath}/templates/${templateName}/js/post.js?${startupTime}"></script>
<script type="text/javascript" src="${contextPath}/templates/${templateName}/js/forum_fn.js?${startupTime}"></script>
<script type="text/javascript">
<#include "js/bbcode_help.js"/>
<#include "js/utils.js"/>
<#include "js/attachments.js"/>
<#include "js/editor.js"/>




</script>

<script type="text/javascript">
<!--
function newCaptcha()
{
	document.getElementById("captcha_img").src = "${contextPath}/jforum${extension}?module=captcha&action=generate&timestamp=" + new Date().getTime();
}

function validatePostForm(f)
{
	<#if setType?default(true)>
	if (f.subject.value == "") {
		alert("${I18n.getMessage("PostForm.subjectEmpty")}");
		f.subject.focus();
		
		return false;
	}
	</#if>
	
	if (f.message.value.replace(/^\s*|\s*$/g, "").length == 0) {
		alert("${I18n.getMessage("PostForm.textEmpty")}");
		f.message.focus();
		
		return false;
	}

	<#if !forum?exists>
	if (f.toUsername.value == "") {
		alert("${I18n.getMessage("PrivateMessage.toUserIsEmpy")}");
		f.toUsername.focus();

		return false;
	}
	</#if>

	<#if logModeration>
	if (f.log_description.value == "") {
		alert("${I18n.getMessage("ModerationLog.reasonIsEmpty")}");
		f.log_description.focus();

		return false;
	}
	</#if>
	
	$("#icon_saving").css("display", "inline");
	$("#btnPreview").attr("disabled", "disabled");
	$("#btnSubmit").attr("disabled", "disabled").val("${I18n.getMessage("PostForm.saving")}...");
	
	return true;
}

function openFindUserWindow()
{
	var w = window.open("${JForumContext.encodeURL("/pm/findUser")}", "_findUser", "height=250,resizable=yes,width=400");
	w.focus();
}

function smiliePopup()
{
	var w = window.open("${JForumContext.encodeURL("/posts/listSmilies")}", "smilies", "width=300, height=300, toolbars=no, scrollbars=yes");
	w.focus();
}

-->
</script>

<#assign preview = preview?exists && preview/>
<#assign isNewPost = isNewPost?exists && isNewPost/>
<#assign isEdit = isEdit?if_exists/>
<#assign isNewTopic = (!topic?exists || topic.id == -1)/>
<#assign attachmentsEnabled = attachmentsEnabled?exists && attachmentsEnabled/>

<#if !maxAttachments?exists>
	<#assign maxAttachments = 0/>
</#if>

<#assign htmlChecked = "checked=\"checked\""/>
<#assign bbChecked = ""/>
<#assign signatureChecked = "checked=\"checked\""/>
<#assign repliesChecked = "checked=\"checked\""/>
<#assign smiliesChecked = ""/>

<#if isNewPost && !preview && !post?exists>
	<#if user.isHtmlEnabled()><#assign htmlChecked = ""/></#if>
	<#if !user.isBbCodeEnabled()><#assign bbChecked = "checked=\"checked\""/></#if>
	<#if !user.isSmiliesEnabled()><#assign smiliesChecked = "checked=\"checked\""/></#if>
	<#if !user.getAttachSignatureEnabled()><#assign signatureChecked = ""/></#if>
<#elseif post?exists>
	<#if post.isHtmlEnabled()><#assign htmlChecked = ""/></#if>
	<#if !post.isBbCodeEnabled()><#assign bbChecked = "checked=\"checked\""/></#if>
	<#if !post.isSmiliesEnabled()><#assign smiliesChecked = "checked=\"checked\""/></#if>
	<#if !post.isSignatureEnabled()><#assign signatureChecked = ""/></#if>
</#if>

<#if !user.isNotifyOnMessagesEnabled()><#assign repliesChecked = ""/></#if>

<form action="${JForumContext.encodeURL("/jforum")}" method="post" enctype="multipart/form-data" name="postform" id="postform" onsubmit="return validatePostForm(this)">
<input type="hidden" name="action" value="${action}" />
<input type="hidden" name="module" value="${moduleName}" />
<input type="hidden" name="preview" value="0"/>
<#if forum?exists><input type="hidden" name="forum_id" value="${forum.id}" /></#if>
<input type="hidden" name="start" value="${start?default("")}" />
<#if isEdit><input type="hidden" name="post_id" value="${post.id}" /></#if>
<#if !isNewTopic><input type="hidden" name="topic_id" value="${topic.id}" /></#if>


            <#if forum?exists>
                 <h2><a href="${JForumContext.encodeURL("/forums/show/${forum.id}")}">${forum.name}</a></h2>
			</#if>



			<!-- Preview message -->
			<div id="preview" <#if !preview>style="display: none"</#if>>
			<div class="post bg2" id="previewTable" >
	            <div class="inner"><span class="corners-top"><span></span></span>
                <div class="postbody">
                    <h3>${I18n.getMessage("PostForm.preview")}: <span id="previewSubject"><#if postPreview?exists>${postPreview.subject?html}</#if></span></h3>
                    <div class="content" id="previewMessage"><#if postPreview?exists>${postPreview.text}</#if></div>
                </div>
            	<span class="corners-bottom"><span></span></span></div>
            </div>
            <hr />
            </div>







<div class="panel" id="postingbox">
	<div class="inner"><span class="corners-top"><span></span></span>
	
	<h3>
						<#if forum?exists>
							<#if (topic?exists && topic.id > -1)>
							    <#if isEdit>
							    	${I18n.getMessage("PostForm.edit")}
							    <#else>
									${I18n.getMessage("PostForm.reply")}
								</#if>
							<#else>
								${I18n.getMessage("PostForm.title")}
							</#if>
						<#else>
							<#if pmReply?default(false)>
								${I18n.getMessage("PrivateMessage.reply")}
							<#else>
								${I18n.getMessage("PrivateMessage.title")}
							</#if>
						</#if>
	</h3>

				<#if errorMessage?exists>
				    <p class="error">${errorMessage}</p>
				</#if>



<fieldset class="fields1">
				<#if !forum?exists>
	                <dl class="clear: left;">
				        <dt><label for="toUsername">${I18n.getMessage("PrivateMessage.user")}:</label></dt>
				        <#if pmRecipient?exists>
							<#assign toUsername = toUsername/>
							<#assign toUserId = toUserId/>
							<#elseif preview>
							<#assign toUsername = pm.toUser.username/>
							<#assign toUserId = pm.toUser.id/>
							<#elseif quote?default("") == "true" || pmReply?default(false)>
							<#assign toUsername = pm.fromUser.username/>
							<#assign toUserId = pm.fromUser.id/>
						<#else>
							<#assign toUsername = ""/>
							<#assign toUserId = ""/>
						</#if>

						<dd>
						<input type="text" class="inputbox autowidth" size="25" maxlength="60" id="toUsername" name="toUsername" value="${toUsername}"/>
						<input type="button" value="${I18n.getMessage("PrivateMessage.findUser")}" name="findUser" class="button2" onclick="openFindUserWindow(); return false;" />
						<input type="hidden" name="toUserId" value="${toUserId}" />
				        </dd>
			        </dl>
				</#if>
	
	<dl style="clear: left;">
	               <#if post?exists>
						<#assign subject = post.subject?default("")?html/>
						<#elseif pmReply?default(false)>
						<#assign subject = pm.post.subject?html/>
						<#elseif topic?exists>
						<#assign subject = I18n.getMessage("Message.replyPrefix") + topic.title?default("")?html/>
					</#if>
		<dt><label for="subject">${I18n.getMessage("PostForm.subject")}:</label></dt>
		<dd><input type="text" name="subject" id="subject" size="45" maxlength="100" tabindex="2" class="inputbox autowidth" value="${subject?default("")}"></dd>
	</dl>
	
	
					
	
	
	
	<script type="text/javascript">
// <![CDATA[
	var form_name = 'postform';
	var text_name = 'message';
	var load_draft = false;
	var upload = false;

	// Define the bbCode tags
	var bbcode = new Array();
	var imageTag = false;

	var panels = new Array('options-panel', 'attach-panel', 'poll-panel');
	var show_panel = 'options-panel';


// ]]>
</script>



<div id="colour_palette" style="display: none;">
	<dl style="clear: left;">
	
		<dt><label>${I18n.getMessage("PostForm.fontColour")}:</label></dt>
		<dd>
		<script type="text/javascript">
		// <![CDATA[
			function change_palette()
			{
				dE('colour_palette');
				e = document.getElementById('colour_palette');
				
				if (e.style.display == 'block')
				{
					document.getElementById('bbpalette').value = '${I18n.getMessage("PostForm.hideFontColour")}';
				}
				else
				{
					document.getElementById('bbpalette').value = 'Font colour';
				}
			}

			colorPalette('h', 15, 10);
		// ]]>
		</script>
		</dd>
	</dl>
</div>

<div id="format-buttons">
						<input class="button2" onmouseover="helpline('b')" style="FONT-WEIGHT: bold; WIDTH: 30px" accesskey="b" onclick="bbstyle(0)" type="button" value=" B " name="addbbcode0" /> 
							<input class="button2" onmouseover="helpline('i')" style="WIDTH: 30px; FONT-STYLE: italic" accesskey="i" onclick="bbstyle(2)" type="button" value=" i " name="addbbcode2" /> 
							<input class="button2" onmouseover="helpline('u')" style="WIDTH: 30px; TEXT-DECORATION: underline" accesskey="u" onclick="bbstyle(4)" type="button" value=" u " name="addbbcode4" />
							<input class="button2" onmouseover="helpline('q')" style="WIDTH: 50px" accesskey="q" onclick="bbstyle(6)" type="button" value="Quote" name="addbbcode6" /> 
							<input class="button2" onmouseover="helpline('c')" style="WIDTH: 40px" accesskey="c" onclick="bbstyle(8)" type="button" value="Code" name="addbbcode8" />
							<input class="button2" onmouseover="helpline('l')" style="WIDTH: 40px" accesskey="l" onclick="bbstyle(10)" type="button" value="List" name="addbbcode10" />
							<input class="button2" onmouseover="helpline('p')" style="WIDTH: 40px" accesskey="p" onclick="bbstyle(12)" type="button" value="Img" name="addbbcode12" />
							<input class="button2" onmouseover="helpline('w')" style="WIDTH: 40px" accesskey="w" onclick="bbstyle(14)" type="button" value="URL" name="addbbcode14" />
							<input class="button2" onmouseover="helpline('g')" style="WIDTH: 50px" accesskey="g" onclick="bbstyle(16)" type="button" value="Google" name="addbbcode16" />
							<input class="button2" onmouseover="helpline('y')" style="WIDTH: 60px" accesskey="y" onclick="bbstyle(18)" type="button" value="Youtube" name="addbbcode18" />
							<input class="button2" onmouseover="helpline('k')" style="WIDTH: 40px" accesskey="k" onclick="bbstyle(20)" type="button" value="Flash" name="addbbcode20" />
							<input class="button2" onmouseover="helpline('v')" style="WIDTH: 40px" accesskey="v" onclick="bbstyle(22)" type="button" value="WMV" name="addbbcode22" />

	                        <select onmouseover="helpline('f')" onchange="bbfontstyle('[size=' + this.form.addbbcode26.options[this.form.addbbcode26.selectedIndex].value + ']', '[/size]')" name="addbbcode26"> 
											<option value="7">${I18n.getMessage("PostForm.fontVerySmall")}</option> 
											<option value="9">${I18n.getMessage("PostForm.fontSmall")}</option> 
											<option value="12" selected="selected">${I18n.getMessage("PostForm.fontNormal")}</option> 
											<option value="18">${I18n.getMessage("PostForm.fontBig")}</option> 
											<option value="24">${I18n.getMessage("PostForm.fontGiant")}</option>
							</select>
							<select onmouseover="helpline('s')" onchange="bbfontstyle('[color=' + this.form.addbbcode24.options[this.form.addbbcode24.selectedIndex].value + ']', '[/color]')" name="addbbcode24"> 
											<option style="COLOR: black; BACKGROUND-COLOR: #fafafa" value="#444444" selected="selected">${I18n.getMessage("PostForm.colorDefault")}</option> 
											<option style="COLOR: darkred; BACKGROUND-COLOR: #fafafa" value="darkred">${I18n.getMessage("PostForm.colorDarkRed")}</option> 
											<option style="COLOR: red; BACKGROUND-COLOR: #fafafa" value="red">${I18n.getMessage("PostForm.colorRed")}</option> 
											<option style="COLOR: orange; BACKGROUND-COLOR: #fafafa" value="orange">${I18n.getMessage("PostForm.colorOrange")}</option> 
											<option style="COLOR: brown; BACKGROUND-COLOR: #fafafa" value="brown">${I18n.getMessage("PostForm.colorBrown")}</option> 
											<option style="COLOR: yellow; BACKGROUND-COLOR: #fafafa" value="yellow">${I18n.getMessage("PostForm.colorYellow")}</option> 
											<option style="COLOR: green; BACKGROUND-COLOR: #fafafa" value="green">${I18n.getMessage("PostForm.colorGreen")}</option> 
											<option style="COLOR: olive; BACKGROUND-COLOR: #fafafa" value="olive">${I18n.getMessage("PostForm.colorOlive")}</option> 
											<option style="COLOR: cyan; BACKGROUND-COLOR: #fafafa" value="cyan">${I18n.getMessage("PostForm.colorCyan")}</option> 
											<option style="COLOR: blue; BACKGROUND-COLOR: #fafafa" value="blue">${I18n.getMessage("PostForm.colorBlue")}</option> 
											<option style="COLOR: darkblue; BACKGROUND-COLOR: #fafafa" value="darkblue">${I18n.getMessage("PostForm.colorDarkBlue")}</option> 
											<option style="COLOR: violet; BACKGROUND-COLOR: #fafafa" value="violet">${I18n.getMessage("PostForm.colorViolet")}</option> 
											<option style="COLOR: white; BACKGROUND-COLOR: #fafafa" value="white">${I18n.getMessage("PostForm.colorWhite")}</option>
											<option style="COLOR: black; BACKGROUND-COLOR: #fafafa" value="black">${I18n.getMessage("PostForm.colorBlack")}</option>
										</select> 
	

	<input onmouseover="helpline('s')" type="button" class="button2" name="bbpalette" id="bbpalette" value="${I18n.getMessage("PostForm.fontColour")}" onclick="change_palette();">
	<dd><input name="helpbox" class="helpline" readonly="readonly" style="FONT-SIZE: 10px; WIDTH: 100%" value="${I18n.getMessage("PostForm.helplineTip")}" size="45" maxlength="100" /></dd>
	
</div>


					<div id="smiley-box">
					                    <strong>${I18n.getMessage("PostForm.smiles")}</strong><br />
										<#assign count = 0/>
										<#assign lastSmilie = ""/>
											<#list smilies as smilie>
												<#if (count < 20)>
													<#if lastSmilie == "" || lastSmilie.url != smilie.url>
														<a href="javascript:emoticon('${smilie.code}');">${smilie.url}</a></td>
														<#assign count = count + 1/>
														<#assign lastSmilie = smilie/>
													</#if>
												</#if>
											</#list>

											<#if !(count % 4 == 0)>
											</#if>
											<hr />
											<a href="#" onclick="smiliePopup();return false;">${I18n.getMessage("PostForm.moreSmilies")}</a>
						</div>


	<div id="message-box">
		<textarea name="message" id="message" rows="15" cols="76" tabindex="4" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);" onfocus="initInsertions();" class="inputbox"><#if post?exists><#if quote?exists>[quote=${quoteUser}]${post.text?html}[/quote]<#else>${post.text?html}</#if></#if></textarea>
	</div>
</fieldset>
		<span class="corners-bottom"><span></span></span></div>
	</div>
	





				<#if needCaptcha?default(false)>
					<#include "captche.htm"/>
				</#if>

				<#if logModeration>
<div class="panel">
	<div class="inner"><span class="corners-top"><span></span></span>

<h3>${I18n.getMessage("ModerationLog.moderationLog")}</h3>
	<fieldset class="fields2">
	
	<dl>
		<dt><label for="log_description">${I18n.getMessage("ModerationLog.changeReason")}</label></dt>
		<dd><input type="text" name="log_description" size="50" class="inputbox autowidth"/><input type="hidden" name="log_type" value="2" /></dd>
	</dl>

	</fieldset>
	<span class="corners-bottom"><span></span></span></div>
</div>
</#if>

	<div class="panel bg2">
		<div class="inner"><span class="corners-top"><span></span></span>
		<fieldset class="submit-buttons">
			
			<input type="hidden" name="lastclick" value="1383295923">
 			<input class="button1" id="btnPreview" tabindex="5" type="button" value="${I18n.getMessage("PostForm.preview")}" onclick="previewMessage();" />&nbsp;
			<input class="button1 default-submit-action" id="btnSubmit" accesskey="s" tabindex="6" type="submit" value="${I18n.getMessage("PostForm.submit")}" name="postform" />
		</fieldset>

		<span class="corners-bottom"><span></span></span></div>
	</div>



	
		<div id="tabs">
			<ul>
			    <li id="options-panel-tab" class="activetab"><a href="#tabs" onClick="subPanels('options-panel'); return false;"><span>${I18n.getMessage("Options")}</span></a></li>
				<#if attachmentsEnabled>
    				<li id="attach-panel-tab" class=""><a href="#tabs" onclick="subPanels('attach-panel'); return false;"><span>${I18n.getMessage("uploadAttachment")}</span></a></li>
				</#if>
				<#if allowPoll>
    				<li id="poll-panel-tab" class=""><a href="#tabs" onclick="subPanels('poll-panel'); return false;"><span>${I18n.getMessage("pollCreation")}</span></a></li>
				</#if>

			</ul>
		</div>
		
								<!-- Post Options -->
						<div class="panel bg3" id="options-panel" style="display: block;">
								<#include "post_options_tab.htm"/>
						</div>

						<!-- Attachments tab -->
						<#if attachmentsEnabled || attachments?exists>
							<div class="panel bg3" id="attach-panel" style="display: none;">
									<#include "post_attachments_tab.htm"/>
							</div>
						</#if>

						<!-- Poll tab -->
						<#if allowPoll>
							<div class="panel bg3" id="poll-panel" style="display: none;">
									<#include "post_poll_tab.htm"/>
							</div>
						</#if>


	<#if ((topic?exists && topic.id > 0) || pmReply?default(false))>

						<h3 id="review">

	                    <span class="right-box"><a href="#review" onclick="viewableArea(getElementById('topicreview'), true); var rev_text = getElementById('review').getElementsByTagName('a').item(0).firstChild; if (rev_text.data == '${I18n.getMessage("PostShow.expandView")}'){rev_text.data = '${I18n.getMessage("PostShow.collapseView")}'; } else if (rev_text.data == '${I18n.getMessage("PostShow.collapseView")}'){rev_text.data = '${I18n.getMessage("PostShow.expandView")}'};">${I18n.getMessage("PostShow.expandView")}</a></span>
	                   
	                    
	                    <#if pmReply?default(false)>
						${I18n.getMessage("PostShow.messageReview")}:</h3>
						 <div id="topicreview">
				        <script type="text/javascript">
	                    // <![CDATA[
	                    	bbcodeEnabled = 1;
	                    // ]]>
	                    </script>
	                    

	

	<div class="post bg2">
		<div class="inner"><span class="corners-top"><span></span></span>
	

       <div class="postbody" id="pr1">
			<h3><a href="${JForumContext.encodeURL("/pm/read/${pm.id}")}" class="current">${pm.post.subject?html}</a></h3>
			<p class="author"> ${I18n.getMessage("PrivateMessage.date")}: <strong>${pm.formatedDate}</strong><br>
				${I18n.getMessage("by")} <a href="${JForumContext.encodeURL("/user/profile/${pm.fromUser.id}")}" style="color: #AA0000;" class="username-coloured">${pm.fromUser.username}</a></p>
			<div class="content">${pm.post.text}</div>
			<#if (pm.fromUser.attachSignatureEnabled && pm.fromUser.signature?exists && pm.post.isSignatureEnabled())>
					<div class="signature">${pm.fromUser.signature}</div>
			</#if>
		</div>
		<span class="corners-bottom"><span></span></span></div>
	</div>

						
					<#else>
                        ${I18n.getMessage("PostShow.topicReview")} : ${topic.id}</h3>
	                    
	                    <div id="topicreview">
				        <script type="text/javascript">
	                    // <![CDATA[
	                    	bbcodeEnabled = 1;
	                    // ]]>
	                    </script>
	<#list posts as post>
		<#if post_index % 2 == 0>
			<#assign rowColor = "bg2">
		<#else>
			<#assign rowColor = "bg1">
		</#if>

		<#assign user = users.get(post.userId)/>
		
	<div class="post ${rowColor}">
		<div class="inner"><span class="corners-top"><span></span></span>
	

		<div class="postbody">
			<h3><a href="#pr34">${post.subject?default("")?html}</a></h3>
			<p class="author"><a href="${JForumContext.encodeURL("/posts/list/${post.topicId}")}"><img src="${contextPath}/templates/${templateName}/img/icon_post_target.gif" width="11" height="9" alt="Post" title="Post"></a> by <strong><a href="${JForumContext.encodeURL("/user/profile/${user.id}")}" style="color: #AA0000;" class="username-coloured">${user.username}</a></strong> &raquo; ${post.formatedTime}  </p>
			<div class="content">${post.text}</div>
		</div>
		<span class="corners-bottom"><span></span></span></div>
	</div>
	</#list>

	                    
	

					</#if>
<#if hasCodeBlock?default(false)>
	<#include "highlighter_js.htm"/>
</#if>

</div>
	                    


	</#if>


<script type="text/javascript">
<!--
<#if attachments?exists>
	ignoreStart = true;
	editAttachments();
</#if>

<#if preview>document.location = "#preview";</#if>
-->
</script>

</form>

<#include "highlighter_js.htm"/>
<#include "bottom.htm"/>